//
//  XLAllIndexCell.m
//  industry
//
//  Created by xl on 2020/11/27.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLAllIndexCell.h"
#import "XLHomeIndexModel.h"

@interface XLAllIndexCell ()

@property (nonatomic, strong) XLView *bgView;
@property (nonatomic, strong) XLLabel *titleLB;
@property (nonatomic, strong) XLLabel *infoLB;

@end
@implementation XLAllIndexCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self.contentView addSubview:self.bgView];
        [_bgView addSubview:self.titleLB];
        [_bgView addSubview:self.infoLB];
        
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(30);
            make.right.equalTo(self.contentView).offset(-30);
            make.top.bottom.equalTo(self.contentView);
        }];
        
        [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.bgView);
            make.left.equalTo(self.bgView).offset(20);
        }];
        
        [_infoLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bgView).offset(-12);
            make.centerY.equalTo(self.bgView);
            make.left.greaterThanOrEqualTo(self.titleLB.mas_right).offset(10);
        }];
    }
    return self;
}

#pragma mark - Public
- (void)loadCellData:(XLHomeIndexModel *)model {
    _titleLB.text = model.indicatorsName;
    _infoLB.text = ISEmptyString(model.data) ? @"暂无信息":model.data;
}

#pragma mark - Setter/getter
- (XLView *)bgView {
    if (!_bgView) {
        _bgView = [XLView new];
        _bgView.backgroundColor = [UIColor grayBgColor];
        _bgView.layer.cornerRadius = 12.0f;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}

- (XLLabel *)titleLB {
    if (!_titleLB) {
        _titleLB = [XLLabel new];
        _titleLB.font = [UIFont fontOfPingFangSCSemiboldWithSize:13];
        _titleLB.textColor = [UIColor blackFontColor];
    }
    return _titleLB;
}

- (XLLabel *)infoLB {
    if (!_infoLB) {
        _infoLB = [XLLabel new];
        _infoLB.font = [UIFont fontOfPingFangSCSemiboldWithSize:13];
        _infoLB.textColor = [UIColor grayFontColor];
    }
    return _infoLB;
}

@end
